;*****************************************************
; 	Copyright (C) SEIKO EPSON CORP. 1997-2001
;	All rights Reserved
;
;	File name : strcat.s
;	Function  :
;	       This is strcat function
;	Revision  :
;		1997/03/24	V.Chan start
;		2001/12/06	T.Tazaki for GNU33(Linux)
;*****************************************************

;*****************************************************
; strcat
;		string append from src to end of dest (0 terminated)
;		appends 0 as well
;
; arguments : %r6:dest addr, %r7:src addr
; return    : %r4:dest addr
;*****************************************************

	.section .text
	.align 1
	.global strcat
	.type	strcat,@function

strcat:
	ld.w 	%r4, %r6		; return dest add
	
pos_loop:
	ld.ub	%r10, [%r6]+	; position to end of dest
	cmp		%r10, 0
	jrne	pos_loop

	sub		%r6, 1		; position on NULL byte

strcat_loop:
	ld.ub	%r10, [%r7]+	; copy src 1 byte to dest
	ld.b	[%r6]+, %r10
	cmp		%r10, 0
	jrne	strcat_loop
	ret


